package com.vincent.template.repository;

import com.vincent.template.commons.base.BaseJpaRepository;
import com.vincent.template.domain.BizDepartmentPo;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @Author Vincent Wang
 * @Date 2020/10/19 13:44
 */
public interface BizDepartmentRepository extends BaseJpaRepository<BizDepartmentPo, String> {

    BizDepartmentPo findByDepartmentNo(long departmentNo);

    List<BizDepartmentPo> findByParentNo(long parentNo);

    @Query(value = "SELECT IFNULL(MAX(departmentNo), -1) FROM department", nativeQuery = true)
    Long getMaxDepartmentNo();
}
